import cv2
import numpy as np
img=cv2.imread('CV-Pictures/blackhat.bmp')
kernel=np.ones((11,11),np.uint8)
black_img= cv2.morphologyEx(img,cv2.MORPH_BLACKHAT,kernel)
cv2.imshow("img",img)
cv2.imshow('black_hat',black_img)
cv2.waitKey(0)
cv2.destroyAllWindows()